package com.guldan.thrall.web.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.guldan.core.controller.BaseController;
import com.guldan.core.dubbo.client.ResponseDTO;
import com.guldan.core.response.ResponseJson;
import com.guldan.jaina.dto.projectextensiondic.ProjectExtensionDicDTO;
import com.guldan.jaina.dto.projectextensiondic.ProjectExtensionDicSearchDTO;
import com.guldan.jaina.provider.IProjectProvider;

/**
 * Created by Silas.
 * Date: 2016/11/10
 * Time: 22:06
 */
@Controller
@RequestMapping("/projectExtensionDic")
public class ProjectExtensionDicController extends BaseController {
    @Autowired
    private IProjectProvider iProjectProvider;

    //获取单个项目扩展属性
    @RequestMapping(value = "/get", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    ProjectExtensionDicDTO get(@RequestBody ProjectExtensionDicDTO dto) {
        ResponseDTO<ProjectExtensionDicDTO> response = iProjectProvider.getProjectExtensionDic(dto.getExtId());
        return response.getData();
    }

    //新增/保存单个项目扩展属性
    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    ProjectExtensionDicDTO save(@RequestBody ProjectExtensionDicDTO dto) {
        ResponseDTO<ProjectExtensionDicDTO> response = iProjectProvider.saveProjectExtensionDic(dto);
        return response.getData();
    }

    //删除单个项目扩展属性
    @RequestMapping(value = "/delete", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    Boolean delete(@RequestBody ProjectExtensionDicDTO dto) {
        ResponseDTO<Boolean> response = iProjectProvider.deleteProjectExtensionDic(dto.getExtId());
        return response.getData();
    }

    /**
     * 获取全部项目扩展属性列表
     * @param dto
     * @return
     */
    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseJson
    public
    @ResponseBody
    List<ProjectExtensionDicDTO> list() {
    	ProjectExtensionDicSearchDTO dto = new ProjectExtensionDicSearchDTO();
    	ResponseDTO<List<ProjectExtensionDicDTO>> response = iProjectProvider.allProjectExtensionDic(dto);
        return response.getData();
    }


}
